﻿package
{
	import core.Util;
	
	import flash.display.Graphics;
	import flash.display.MovieClip;
	import flash.display.Shape;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	public class CardPointTextField extends MovieClip
	{
		public var textField:TextField;
		
	    private var _text:*;
		
		private var border:Shape;
		
		public function CardPointTextField()
		{
			super();
			this.mouseChildren = false;
			this.mouseEnabled = false;
			this.textField.autoSize = TextFieldAutoSize.LEFT;
			border = new Shape();
			this.addChildAt(border,0);
		}
		
		public function set text(value:*):void
		{
			if(value == 0){
				this._text = "";
			}else {
				this._text = Util.fixedNumber(value);
			}
			this.update();
		}
		
		public function get text():int
		{
			return this._text;
		}
		
		
		public function update():void {
			this.textField.text = "" + this._text;
			this.drawBorder();
		}
		
		protected function drawBorder():void {
			var g:Graphics = this.border.graphics;
			g.clear();
			/*if(Number(this.text) == 0){
				return;
			}*/
			g.beginFill(0x000000,0.7);
			var w:Number = this.textField.textWidth + 5;
			g.drawRoundRect(0,0,w,this.textField.height,5,5);
			g.endFill();
		}
	}
}